/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.butid.data.codec;

import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 请求对象
 * 
 * @author wangjingjing@qq.com
 * @version 2020-8-20
 */
@Data
@Accessors(chain = true)
@ToString
public class RequestBody implements Serializable {

    /** for serialization */
    private static final long  serialVersionUID          = 5834538723682531917L;

    public static final String DEFAULT_CLIENT_STR        = "HELLO WORLD! I'm from client";
    public static final String DEFAULT_SERVER_STR        = "HELLO WORLD! I'm from server";
    public static final String DEFAULT_SERVER_RETURN_STR = "HELLO WORLD! I'm server return";
    public static final String DEFAULT_CLIENT_RETURN_STR = "HELLO WORLD! I'm client return";

    public static final String DEFAULT_ONEWAY_STR        = "HELLO WORLD! I'm oneway req";
    public static final String DEFAULT_SYNC_STR          = "HELLO WORLD! I'm sync req";
    public static final String DEFAULT_FUTURE_STR        = "HELLO WORLD! I'm future req";
    public static final String DEFAULT_CALLBACK_STR      = "HELLO WORLD! I'm call back req";

    /** id */
    private String id;

    /**指令类型*/
    private String cmdType;

    /**指令代码*/
    private String cmdCode;

    /**终端id*/
    private String clientId;

    /**终端请求序列号*/
    private String clientSeq;

    /**终端请求事件*/
    private String clientTime;

    /**请求数据体*/
    private Map<String, Object> body = new HashMap<>();

    public RequestBody addBody(String name, Object value){
        this.body.put(name, value);
        return this;
    }

    static public enum InvokeType {
        ONEWAY, SYNC, FUTURE, CALLBACK;
    }
}